package com.xbao.controller;

import com.xbao.core.http.CommRequest;
import com.xbao.core.http.CommResult;
import com.xbao.model.req.AskAbsentReq;
import com.xbao.model.req.SubjectReq;
import com.xbao.model.vo.AskAbsentVo;
import com.xbao.service.AskAbsentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 */
@Api(value = "/absent", tags = "absent")
@RequestMapping(value = "absent")
@Controller
@EnableAutoConfiguration
public class AskAbsentController extends BaseController {
    @Resource
    private AskAbsentService askAbsentService;

    @ApiOperation(value = "askAbsent", notes = "askAbsent")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ResponseBody
    public CommResult askAbsent(@RequestBody CommRequest<AskAbsentReq> askAbsentReqCommRequest) {
       askAbsentService.addAskAbsent(askAbsentReqCommRequest.getData());
        return result();
    }

    @ApiOperation(value = "queryDealAbsentList", notes = "queryDealAbsentList")
    @RequestMapping(value = "/queryDealAbsentList", method = RequestMethod.POST)
    @ResponseBody
    public CommResult queryDealAbsentList(@RequestBody CommRequest<AskAbsentReq> askAbsentReqCommRequest) {
        List<AskAbsentVo> vos= askAbsentService.queryAskAbsentList(askAbsentReqCommRequest.getData());
        return new CommResult(vos);
    }
    @ApiOperation(value = "confirmAbsent", notes = "confirmAbsent")
    @RequestMapping(value = "/confirmAbsent", method = RequestMethod.POST)
    @ResponseBody
    public Object confirmAbsent(@RequestBody CommRequest<AskAbsentReq> askAbsentReqCommRequest) {
        askAbsentService.confirmAskAbsent(askAbsentReqCommRequest.getData());
        return result();
    }
    @ApiOperation(value = "cancelAskAbsent", notes = "confirmAbsent")
    @RequestMapping(value = "/cancelAskAbsent", method = RequestMethod.POST)
    @ResponseBody
    public Object cancelAskAbsent(@RequestBody CommRequest<AskAbsentReq> askAbsentReqCommRequest) {
        askAbsentService.deleteAskAbsent(askAbsentReqCommRequest.getData());
        return result();
    }
    @ApiOperation(value = "askAbsentMainPage", notes = "askAbsentMainPage")
    @RequestMapping(value = "/askAbsentMainPage", method = RequestMethod.POST)
    @ResponseBody
    public CommResult queryAskAbsentMainPage(@RequestBody CommRequest<AskAbsentReq> askAbsentReqCommRequest) {
       List<AskAbsentVo> vos= askAbsentService.queryAskAbsentMainPage(askAbsentReqCommRequest.getData());
        return new CommResult(vos);
    }

}
